<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .father {
            width: 300px;
            height: 300px;
            border: 1px solid #000;
        }
        .son {
            width: 100px;
            height: 100px;
            background-color: #0f0;
        }
    </style>
</head>

<body>
    <div id="app">
        <div @click.self="fatherFn" class="father">
            <!-- .prevent 阻止默认行为 -->
            <a href="http://www.baidu.com" @click.prevent="fn1">点我跳转</a>
            <!-- 阻止冒泡 -->
            <button @click.stop="fn2">点我</button>

            <!-- 阻止默认行为，又想阻止冒泡，就可以连着写事件修饰符 -->
            <!-- 写几个就有几个有效果，没有顺序之分 -->
            <a href="http://www.baidu.com" @click.stop.prevent="fn1">点我跳转</a>

            <!-- 只触发一次 -->
            <button @click.once="fn1">我只能被点1次哟！</button>

            <div class="son"></div>
            <div class="son"></div>
            <div class="son"></div>
        </div>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {

            },
            methods: {
                fn1() {
                    alert(123)
                },
                fn2 () {
                    alert('按钮被点了')
                },
           
                fatherFn () {
                    alert('父盒子被点了')
                }
            }

        })
    </script>
</body>

</html>